package ch.zhaw.cctd.domain.player;

import java.awt.Point;
import java.io.Serializable;

import ch.zhaw.cctd.domain.GraphicalElement;
import ch.zhaw.cctd.domain.map.MapElement;
import ch.zhaw.cctd.domain.prototype.MapElementPrototype;

/**
 * Verantwortlich für das Tower placement. Bildet intern einen Grid ab und
 * beinhaltet die Tower Liste
 * 
 * @author Rolf Koch
 * 
 */

public class ConstructionZone extends MapElement implements GraphicalElement, Serializable {

	/**
	 * Serializable ID
	 */
	private static final long serialVersionUID = -4821435199225934738L;
	
	/**
	 *  Default Rastersize for Tower Building
	 */
	private static final int RASTERSIZE = 20;


	/**
	 * Default Constructor
	 * @param mapElementPrototype
	 * @param texture
	 */
	public ConstructionZone(MapElementPrototype mapElementPrototype, String texture) {
		super(mapElementPrototype, texture);
	}

	/**
	 * Returns the left top corner Point of the current Grid Field the Point p
	 * is in.
	 * 
	 * @param p
	 * @return
	 */
	public static Point getGridLocation(Point p) {

		int x = (int) (p.getX() - p.getX() % RASTERSIZE);
		int y = (int) (p.getY() - p.getY() % RASTERSIZE);

		return new Point(x, y);

	}

}
